﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="KaiCaiJHSR.aspx.cs" Inherits="Web.Pages.QuShui.DiXiaS.JiHuaGL.KaiCaiJH.KaiCaiJHSR" Theme="Default"%>
<%@ Register Assembly="DevExpress.Web.v15.2, Version=15.2.9.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web" TagPrefix="dx" %>
<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>开采计划输入</title>
        <script src="../../../../../JS/AddEditCancel.js"></script>
    <script src="../../../../../JS/jquery.js"></script>
        <script type="text/javascript">

        function display(op, id) {
            hdCollection.Set("ID", id);
            if (op == "edit") {
                //listCover(true, "divList");
                //$("#GridViewContentTable").show();
                cmUnit.SetValue(1);
                ASPxCallback1.PerformCallback("setinfo");
            }
            else {
                //$("#GridViewContentTable").hide();
               // listCover(false, "divList");
            }
        }

    
        function save() {
            if (txtKaiCaiJH.GetText() == "") {
                alert("开采计划不能为空！");
                txtKaiCaiJH.Focus();
                return;
            }
            ASPxCallback1.PerformCallback("save");
        }

        function Search() {
            //txtKaiCaiJH.Focus();
            //txtKaiCaiJH.SelectAll();
            hdCollection.Set("yhh", txtyhh.GetText());
            ASPxCallback1.PerformCallback("search");           
            //txtKaiCaiJH.Focus();
            //txtKaiCaiJH.SelectAll();
           
        }



       
        var row;//当前记录数
        var rows;//总记录数

        $(function () {
            row = $('#row').val();
            rows = $('#rows').val();
            first();
        });
        //第一条
        function first() {
            //txtKaiCaiJH.Focus();
            //txtKaiCaiJH.SelectAll();
            //alert(row + ' ' + rows);
            row = 1;
            var str = '当前记录：1';
            lbdqjl.SetText(str);
            //hdCollection.Set("ch", '0');
            hdCollection.Set("RN", row);
            ASPxCallback1.PerformCallback("first");

           
        }

        //上一条
        function last() {
            //txtKaiCaiJH.Focus();
            //txtKaiCaiJH.SelectAll();
            if (row <= 1) {
                alert("当前已是第一条");
            }
            else {
                row = parseInt(row) - 1;
                hdCollection.Set("RN", row);
                ASPxCallback1.PerformCallback("last");
            }
            var str = '当前记录：' + row;
            lbdqjl.SetText(str);

            
        }

        //下一条
        function next() {
            //txtKaiCaiJH.Focus();
            //txtKaiCaiJH.SelectAll();

            //alert(rows||' '||row);
            if (row >= rows) {
                alert("当前已是最后一条");
            }
            else {
                row = parseInt(row) + 1;
                hdCollection.Set("RN", row);
                ASPxCallback1.PerformCallback("next");
            }
            var str = '当前记录：' + row;
            lbdqjl.SetText(str);
            
        }

        //最后一条
        function final() {
            //txtKaiCaiJH.Focus();
            //txtKaiCaiJH.SelectAll();

            row = rows;
            hdCollection.Set("RN", rows);
            ASPxCallback1.PerformCallback("final");
            var str = '当前记录：' + row;
            lbdqjl.SetText(str);
            
        }



        function ASPxCallback1Complete(rs) {
            var arr = rs.split('|');
            var type = arr[0];
            var state = arr[1];
            if (type == "setinfo") {
                txtyhh.SetText(arr[2]);
                txtyhm.SetText(arr[3]);
                txtKaiCaiJH.SetText(arr[4]);
                txtKaiCaiJH.Focus();
                txtKaiCaiJH.SelectAll();
                btnSave.SetEnabled(true);
            }
            if (type == "search") {
                //alert(arr[3]);
                txtyhm.SetText(arr[3]);
                txtKaiCaiJH.SetText(arr[4]);
                txtKaiCaiJH.Focus();
                txtKaiCaiJH.SelectAll();
                btnSave.SetEnabled(true);
            }
            else if (type == "save") {
                
                if (arr[2] == "true") {
                    alert("保存成功！");
                    //$("#GridViewContentTable").hide();
                    //listCover(false, "divList");
                    var a = "开采计划合计" + arr[3] + "立方米";
                    lbkaicai1.SetText(a);
                    gvList.PerformCallback();
                    txtyhh.Focus();
                    txtyhh.SelectAll();
                    btnSave.SetEnabled(false);
                    
                }
                else {
                    alert("保存失败！");
                }
            }
            else if (type == "first" || type == "last" || type == "next" || type == "final") {
                txtyhh.SetText(arr[2]);
                txtyhm.SetText(arr[3]);
                txtKaiCaiJH.SetText(arr[4]);
                txtKaiCaiJH.Focus();
                txtKaiCaiJH.SelectAll();
                btnSave.SetEnabled(true);
            }

        }

        function begincall() {
            loadpanel1.Show();
        }
        function endcall() {
            loadpanel1.Hide();
            //定位添加或修改的记录
            var oid = hdCollection.Get("OperateID");
            var index = -1;
            if (oid != -1 && typeof (oid) != undefined) {
                for (var i = 0; i < gvList.GetVisibleRowsOnPage() ; i++) {
                    if (gvList.GetRowKey(i) == oid) {
                        index = i;
                    }
                }
                if (index != -1) {
                    gvList.SetFocusedRowIndex(index);
                    gvList.MakeRowVisible(index);
                    hdCollection.Set("OperateID", -1);
                }
            }
        }
        </script>
</head>
<body>
  <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
        <div class="tabletitle1" align="center">
            开采计划输入
        </div>
        <input  id="row" runat="server" type="hidden" />
        <input  id="rows" runat="server" type="hidden"/>
        <dx:ASPxHiddenField ID="hdCollection" ClientInstanceName="hdCollection" runat="server"></dx:ASPxHiddenField>
        <dx:ASPxCallback ID="ASPxCallback1" ClientInstanceName="ASPxCallback1" runat="server" OnCallback="ASPxCallback1_Callback" ClientSideEvents-CallbackComplete="function(s,e){ASPxCallback1Complete(e.result);}"></dx:ASPxCallback>
        <dx:ASPxLoadingPanel ID="ASPxLoadingPanel1" ClientInstanceName="loadpanel1" runat="server" ContainerElementID="gvList" Modal="true" Theme="Metropolis" ShowImage="false" Text="加载中"></dx:ASPxLoadingPanel>
        <div style="height: 3px;"></div>
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>
                <div>
                    <table style="width:100%;">
                          <tr>
                                <td align="right" style="width: 40px">年份：
                                </td>
                                <td>
                                   <%-- <dx:ASPxTextBox ID="txtYear" ClientInstanceName="txtYear" runat="server" Width="80%" MaxLength="4" ClientEnabled="true">
                                    </dx:ASPxTextBox>--%>
                                      <dx:ASPxComboBox ID="cmbYear" runat="server" Width="200" OnSelectedIndexChanged="cmbYear_SelectedIndexChanged" AutoPostBack="true">
                                </dx:ASPxComboBox> 
                                </td>
                               <td>
                                <dx:ASPxLabel ID="lbkaicai1" ClientInstanceName="lbkaicai1" runat="server" Width="300">
                                </dx:ASPxLabel>
                            </td>
                              <td>
                                  <dx:ASPxLabel runat="server" ID="lbzjl" ClientInstanceName="lbzjl" ForeColor="Blue"></dx:ASPxLabel>
                              </td>
                              <td>&nbsp;&nbsp;&nbsp;</td>
                              <td>
                                  <dx:ASPxLabel runat="server" ID="lbdqjl" ClientInstanceName="lbdqjl" Text="当前记录：1" ForeColor="Blue"></dx:ASPxLabel>
                              </td>
                              <%-- <td>
                                <dx:ASPxLabel ID="lbkaicai2"  runat="server" Width="300">
                                </dx:ASPxLabel>
                            </td>  --%>
                            </tr> 
                    </table>
                </div>
                <div id="divList" align="center">
                    <div>
                        <dx:ASPxGridView ID="gvList" ClientInstanceName="gvList" runat="server" AutoGenerateColumns="False" KeyFieldName="ID" Theme="Aqua1" Width="100%" 
                            OnCustomCallback="gvList_CustomCallback" SettingsBehavior-AllowSort="true">
                            <Columns>
                                  <%--<dx:GridViewDataTextColumn FieldName="ID" Caption="编号" Width="5%" >
                                </dx:GridViewDataTextColumn>--%>
                                <dx:GridViewDataTextColumn FieldName="S_YONGHUH" Caption="用户号" Width="30%" >
                                </dx:GridViewDataTextColumn>    
                                <dx:GridViewDataTextColumn FieldName="S_YONGHUM" Caption="用户名" Width="35%">
                                </dx:GridViewDataTextColumn>
                                <dx:GridViewDataTextColumn FieldName="I_KAICAIJH" Caption="开采计划（立方米）" Width="20%">
                                </dx:GridViewDataTextColumn>
                                <dx:GridViewDataTextColumn Width="10%">
                                    <DataItemTemplate>
                                        <a href="#" onclick="display('edit','<%#Eval("ID")%>')">修改</a>
                                    </DataItemTemplate>
                                </dx:GridViewDataTextColumn>
                            </Columns>
                            <Settings VerticalScrollableHeight="315" VerticalScrollBarMode="Auto" />
                            <ClientSideEvents Init="function(s,e){AdjustSize(320,gvList);}" BeginCallback="function(s,e){begincall();}" EndCallback="function(s,e){endcall();}" />
                        </dx:ASPxGridView>
                    </div>
                    <div style="height: 3px;"></div>
                    <div id="GridViewContentTable" >
                        <div class="tabletitle1" align="center">
                            <dx:ASPxLabel ID="lblOperateTip" runat="server" ClientInstanceName="lblOperateTip" Text="修改"></dx:ASPxLabel>
                        </div>
                         
                        <table style="width: 80%; margin: auto; text-align:center;">
                           
                            <tr>
                                <td style="width:100px;" align="right">用户号：
                                </td>
                                <td style="width:120px;">
                                    <dx:ASPxTextBox ID="txtyhh" ClientInstanceName="txtyhh" runat="server" Width="50%" MaxLength="7" ClientEnabled="true">
                                         <ClientSideEvents KeyPress="function(s,e){var key = event.keyCode;if( key==13){Search();}}" />
                                    </dx:ASPxTextBox>
                                </td>
                            </tr>

                            <tr>
                                <td style="width:100px;" align="right">用户名：
                                </td>
                                <td>
                                    <dx:ASPxTextBox ID="txtyhm" ClientInstanceName="txtyhm" runat="server" Width="50%" ForeColor="Black"  ClientEnabled="false">
                                    </dx:ASPxTextBox>
                                </td>
                            </tr>
                            
                            <tr>
                                <td style="width:100px;" align="right">按：
                                </td>
                                <td>
                                    <dx:ASPxComboBox ID="cmUnit" ClientInstanceName="cmUnit" runat="server" Width="15%" ValueType="System.String">
                                    </dx:ASPxComboBox>
                                </td>
                            </tr>   
                            <tr>
                                <td style="width:140px;" align="right">开采计划(立方米)：
                                </td>
                                <td>
                                    <dx:ASPxTextBox ID="txtKaiCaiJH" ClientInstanceName="txtKaiCaiJH" runat="server" Width="50%" ClientEnabled="true"  >
                                        <ClientSideEvents  KeyPress="function(s,e){ OnKeyNext(btnSave);}"/>
                                    </dx:ASPxTextBox>
                                    <%-- KeyUp="function(s,e){inputFloat(s);}" --%>
                                </td>
                            </tr>   
                        </table>
                         <table style="height:50px;">
                                    <tr>
                                        <td style="width: 70px;">
                                            <div onclick="first();">
                                                <img src="../../../../../Images/first.jpg" /></div>
                                        </td>
                                        <td style="width: 70px;">
                                            <div onclick="last();">
                                                <img src="../../../../../Images/last.jpg" /></div>
                                        </td>
                                        <td style="width: 70px;">
                                            <div onclick="next();">
                                                <img src="../../../../../Images/next.jpg" /></div>
                                        </td>
                                        <td style="width: 70px;">
                                            <div onclick="final();">
                                                <img src="../../../../../Images/final.jpg" /></div>
                                        </td>
                                     <td>&nbsp;</td>
                                    </tr>
                                </table> 
                        <table id="GridViewButtonTable" runat="server" style="width: 100%">
                           <%-- <tr>
                                <td>
                                    <hr />
                                </td>
                            </tr>--%>
                            
                                <tr>
                                <td style="text-align:center;width:500px;">
                                    <dx:ASPxButton ID="btnSave" ClientInstanceName="btnSave" runat="server" Text="保存" UseSubmitBehavior="false" AutoPostBack="false">
                                        <ClientSideEvents Click="function(s, e) {save(); }" />
                                    </dx:ASPxButton>
                                    <%-- <dx:ASPxButton ID="btnSave" ClientInstanceName="btnSave" runat="server" Text="保存"  AutoPostBack="false" UseSubmitBehavior="false" ClientEnabled="false">
                                        <ClientSideEvents  Click="function(s,e){Save();}"/>
                                    </dx:ASPxButton> --%>
                                   <%-- <dx:ASPxButton ID="btnCancel" runat="server" Text="放弃" AutoPostBack="false" UseSubmitBehavior="false">
                                        <ClientSideEvents Click="function(s,e){display('init',-1);}" />
                                    </dx:ASPxButton>--%>
                                </td>
                            </tr>
                        </table>
                    </div>
                </div>
            </ContentTemplate>
        </asp:UpdatePanel>
    </form>
</body>
</html>
